package algotithm.weekendrace.leetcode240.test1;

/**
 * @author 25068
 * @Date 2021/5/9 21:38
 * @Title 5750. 人口最多的年份
 */
class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[][] logs = {{1993,1999},{2000,2010}};
        int res = solution.maximumPopulation(logs);
        System.out.println(res);
    }

    public int maximumPopulation(int[][] logs) {
        int ans = 0;
        int max = 0;
        for (int i = 1950; i <= 2050; i++) {
            int tmp = 0;
            for (int[] pair : logs) {
                if (pair[0] <= i && i <= pair[1] - 1) {
                    tmp++;
                }
            }
            if (tmp > max) {
                ans = i;
                max = tmp;
            }
        }
        return ans;
    }
}